package com.ruoyi.project.wceimms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.wceimms.domain.WceimmsIrfDetailItem;
import com.ruoyi.project.wceimms.service.IWceimmsIrfDetailItemService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 井控装置检维修项目Controller
 * 
 * @author hanl
 * @date 2025-02-06
 */
@RestController
@RequestMapping("/wceimms/item")
public class WceimmsIrfDetailItemController extends BaseController
{
    @Autowired
    private IWceimmsIrfDetailItemService wceimmsIrfDetailItemService;

    /**
     * 查询井控装置检维修项目列表
     */
    @PreAuthorize("@ss.hasPermi('wceimms:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(WceimmsIrfDetailItem wceimmsIrfDetailItem)
    {
        startPage();
        List<WceimmsIrfDetailItem> list = wceimmsIrfDetailItemService.selectWceimmsIrfDetailItemList(wceimmsIrfDetailItem);
        return getDataTable(list);
    }

    /**
     * 导出井控装置检维修项目列表
     */
    @PreAuthorize("@ss.hasPermi('wceimms:item:export')")
    @Log(title = "井控装置检维修项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WceimmsIrfDetailItem wceimmsIrfDetailItem)
    {
        List<WceimmsIrfDetailItem> list = wceimmsIrfDetailItemService.selectWceimmsIrfDetailItemList(wceimmsIrfDetailItem);
        ExcelUtil<WceimmsIrfDetailItem> util = new ExcelUtil<WceimmsIrfDetailItem>(WceimmsIrfDetailItem.class);
        util.exportExcel(response, list, "井控装置检维修项目数据");
    }

    /**
     * 获取井控装置检维修项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('wceimms:item:query')")
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") Long projectId)
    {
        return success(wceimmsIrfDetailItemService.selectWceimmsIrfDetailItemByProjectId(projectId));
    }

    /**
     * 新增井控装置检维修项目
     */
    @PreAuthorize("@ss.hasPermi('wceimms:item:add')")
    @Log(title = "井控装置检维修项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WceimmsIrfDetailItem wceimmsIrfDetailItem)
    {
        return toAjax(wceimmsIrfDetailItemService.insertWceimmsIrfDetailItem(wceimmsIrfDetailItem));
    }

    /**
     * 修改井控装置检维修项目
     */
    @PreAuthorize("@ss.hasPermi('wceimms:item:edit')")
    @Log(title = "井控装置检维修项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WceimmsIrfDetailItem wceimmsIrfDetailItem)
    {
        return toAjax(wceimmsIrfDetailItemService.updateWceimmsIrfDetailItem(wceimmsIrfDetailItem));
    }

    /**
     * 删除井控装置检维修项目
     */
    @PreAuthorize("@ss.hasPermi('wceimms:item:remove')")
    @Log(title = "井控装置检维修项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable Long[] projectIds)
    {
        return toAjax(wceimmsIrfDetailItemService.deleteWceimmsIrfDetailItemByProjectIds(projectIds));
    }
}
